<?php if (!defined('THINK_PATH')) exit();?><div class="js-refund-modal">
	<div class="js-cancel modal-backdrop"></div>
	<div class="modal">
		<div class="js-refund-fm address-ui address-fm" method="post" action="/h5/order/refund">
	    	<h4 class="address-fm-title" style="color:#f60"><?php echo ($order['refund_state_str']); ?></h4>
		    <div class="js-address-cancel publish-cancel js-cancel">
		        <div class="cancel-img"></div>
		    </div>
	    	<div class="block form" style="margin:0;max-height: 300px;overflow: auto;">
	    		<?php if(!empty($order['receiver_address'])): ?><div class="express-panel" style="padding: 10px 0;border-bottom: none;">
			        <ul class="express-detail">
			            <li class="clearfix">
			                <span class="name">收货人：<?php echo ($order['receiver_name']); ?></span><span class="tel"><?php echo ($order['receiver_mobile']); ?></span>
			            </li>
			            <li class="address-detail">收货地址：<?php echo ($order['receiver_address']); ?></li>
			        </ul>
			    </div>
			    <div class="block-item">
		            <label>快递单号</label>
		            <?php if(empty($order['refund_express'])): ?><input type="text" class="js-express" placeholder="快递单号">
		            <?php else: ?>
		            <a href="http://m.kuaidi100.com/result.jsp?nu=<?php echo ($order['refund_express']); ?>" target="_blank" style="color:#007aff"><?php echo ($order['refund_express']); ?></a><?php endif; ?>
		        </div><?php endif; ?>
		    	<?php if($order['refund_state'] == 4): ?><div class="block-item" style="color:#f60"><span>拒绝缘由：<?php echo ($order['refund_sremark']); ?></span></div><?php endif; ?>
		        <div class="block-item">
		            <label>退款原因</label>
		            <span><?php echo ($order["refund_reason_str"]); ?></span>
	        	</div>
	        	<?php if($order['refund_num'] > 0): ?><div class="block-item">
		            <label>退货数量</label>
		            <span><?php echo ($order['refund_num']); ?></span>
		        </div><?php endif; ?>
		        <div class="block-item">
		            <label>退款总额</label>
		            <span><?php echo bcadd($order['refund_fee'], $order['refund_post'], 2);?></span>
		        </div>
		        <?php if(!empty($order['refund_endtime'])): ?><div class="block-item">
		            <label><?php echo ($order['refund_state'] == 3 ? '到账' : '结束'); ?>时间</label>
		            <span><?php echo ($order["refund_endtime"]); ?></span>
		        </div><?php endif; ?>
		        <div class="block-item">
		            <label style="vertical-align: top;">退款说明</label>
		            <span style="line-height:13px"><?php echo (htmlspecialchars($order["refund_remark"])); ?></span>
		        </div>
		        <?php if(count($order['refund_images']) > 0): ?><div class="block-item" style="margin: 0;padding: 10px 0 10px;">
		            <table style="width: 100%;min-height: 60px;table-layout: fixed;color: #ddd;">
						<tr class="js-image-list">
							<?php for($i=0; $i<5; $i++){ if(isset($order['refund_images'][$i])){ echo '<td style="border: 1px dashed #ddd;text-align: center;"><img src="'.$order['refund_images'][$i].'" style="width:100%"></td>'; }else{ echo '<td style="border: 1px dashed #ddd;text-align: center;"> </td>'; } } ?>
						</tr>
					</table>
		        </div><?php endif; ?>
		        <?php if(!empty($order['express'])): ?><div class="block-item">
		            <label>快递单号</label>
		            <span><?php echo ($order["refund_express"]); ?></span>
		        </div><?php endif; ?>
	    	</div>
	    	<?php if($order['refund_state'] == 2): ?><div class="action-container">
	            <button type="button" class="js-save_express btn btn-block btn-red">保存快递单号</button>
	        </div><?php endif; ?>
		</div>
	</div>
	<script>
	(function(){
		var $modal = $('.js-refund-modal')
		   ,$express = $modal.find('.js-express');

		// 关闭弹窗
		$modal.find('.js-cancel').on('click', function(){
			$modal.remove();
			return false;
		});
		
		var width = ((document.documentElement.clientWidth - 26) / 5).toFixed(2);
		$modal.find('.js-image-list td').css({width: width, height: width});
		$modal.find('.form').css('max-height', (document.documentElement.clientHeight * 0.7 ).toFixed(2) + 'px');
		
		// 保存快递单号
		$modal.find('.js-save_express').on('click', function(){
			var express_no = $express.val();
			if(express_no.length < 10){
				return toast.show('请输入快递单号'), false
			}
			$.ajax({
				url: '/h5/refund/express',
				data:{refund_id: '<?php echo ($order['refund_id']); ?>', refund_express: express_no},
				type: 'post',
				dataType: 'json',
				success: function(){
					$modal.remove();
					window.location.reload();
				}
			});
			return false;
		});
	})();
	</script>
</div>